package com.oreilly.ez.web;


import com.oreilly.ez.base.R;
import com.oreilly.ez.entity.EzDetail;
import com.oreilly.ez.service.EzDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ezDetails")
public class EzDetailCtrl  extends BaseCtrl<EzDetail> {

    @Autowired
    private EzDetailService ezDetailService;


    /**
     * 新增, 修改
     * @param item
     * @return
     */
    public Object save(@RequestBody EzDetail item){

        return ezDetailService.save(item);
    }


    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    public Object delete(@PathVariable Integer id) {

        ezDetailService.remove(id);
        return R.ok("delete success");
    }


    /**
     * 查询
     * @param item
     * @param pageable
     * @return
     */
    @Override
    public Object find(EzDetail item, @PageableDefault Pageable pageable){

        return ezDetailService.find(item,  pageable);
    }


    /**
     * 查询 by id
     * @param id
     * @return
     */
    @Override
    public Object findOne(@PathVariable Integer id){

        return ezDetailService.findOne(id);
    }


}
